package xmsg

import "sync"

type Pool struct {
	sync.Pool

	FieldDefs *FieldDefs
}

func (this *Pool) Get() *Bitmap32Message {
	v := this.Pool.Get()
	if v == nil {
		return NewMessage(this.FieldDefs)
	}
	return v.(*Bitmap32Message).Clear()
}

func (this *Pool) Put(msg *Bitmap32Message) {
	this.Pool.Put(msg)
}

func NewPool(fdefs *FieldDefs) *Pool {
	return &Pool{FieldDefs: fdefs}
}
